import { Module } from '@nestjs/common';
import { AppController } from './app.controller';// App控制器
import { AppService } from './app.service'; // App服务
import { TypeOrmModule } from '@nestjs/typeorm'// TypeORM模块
import { SwiperModule } from './swiper/swiper.module';// Swiper模块
import { APP_GUARD } from '@nestjs/core';// 应用守卫常量

import { JwtModule } from '@nestjs/jwt'// JWT模块,令牌
import { ConfigModule, ConfigService } from '@nestjs/config'// 配置模块
import { GoodsModule } from './goods/goods.module';// Goods模块
import { UserModule } from './user/user.module';
import { HomeDataModule } from './home-data/home-data.module';


@Module({// 定义AppModule模块
  imports: [// 模块的imports数组
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: '127.0.0.1',
      port: 3306,
      username: 'root',
      password: 'root',
      database: 'mishop',
      autoLoadEntities: true,
      synchronize: true
    }),
    SwiperModule,

    JwtModule.registerAsync({// 异步注册JwtModule
      global: true,
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: () => ({
        secret: 'key',// JWT密钥
        signOptions: {
          expiresIn: '5m',
        },
      }),
    }),
    GoodsModule,
    UserModule,
    HomeDataModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule { }
